let count;
let interval;
let timerId;

self.onmessage = function(event) {
  count = event.data.count;
  interval = event.data.interval;
  startTimer();
};

function startTimer() {
  if (count <= 0) {
    return;
  }
  timerId = setTimeout(function() {
    self.postMessage(--count);
    startTimer();
  }, interval);
}
